package com.cabrida.livestar.main;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.cabrida.livestar.R;
import com.cabrida.livestar.model.StarGiftData;

/**
 * 粉丝端礼物adapter
 * 
 * @author why
 * 
 */
public class FansGiftGvAdapter extends BaseAdapter {

	private LayoutInflater mInflater;
	private ArrayList<StarGiftData> data_list = new ArrayList<StarGiftData>();

	public FansGiftGvAdapter(Context context) {
		this.mInflater = LayoutInflater.from(context);
	}

	public void setData(ArrayList<StarGiftData> data) {
		data_list = data;
	}

	@Override
	public int getCount() {
		return data_list.size();
	}

	@Override
	public Object getItem(int arg0) {
		return data_list.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		ViewHolder holder = null;
		if (convertView == null) {

			holder = new ViewHolder();

			convertView = mInflater.inflate(
					R.layout.adapter_fans_gift_gv_item, null);
			holder.imageView = (ImageView) convertView.findViewById(R.id.imageView);
			convertView.setTag(holder);

		} else {
			holder = (ViewHolder) convertView.getTag();

		}
		if (position==0) {
			if (data_list.get(position).isIscheck()) {
				holder.imageView.setImageResource(R.drawable.flower_r1_c1_press);
			}else {
				holder.imageView.setImageResource(R.drawable.flower_r1_c1);
			}
		}
		if (position==1) {
			if (data_list.get(position).isIscheck()) {
				holder.imageView.setImageResource(R.drawable.flower_r1_c3_press);
			}else {
				holder.imageView.setImageResource(R.drawable.flower_r1_c3);
			}
		}
		if (position==2) {
			if (data_list.get(position).isIscheck()) {
				holder.imageView.setImageResource(R.drawable.flower_r1_c4_press);
			}else {
				holder.imageView.setImageResource(R.drawable.flower_r1_c4);
			}
		}
		if (position==3) {
			if (data_list.get(position).isIscheck()) {
				holder.imageView.setImageResource(R.drawable.flower_r2_c1_press);
			}else {
				holder.imageView.setImageResource(R.drawable.flower_r2_c1);
			}
		}
		if (position==4) {
			if (data_list.get(position).isIscheck()) {
				holder.imageView.setImageResource(R.drawable.flower_r2_c3_press);
			}else {
				holder.imageView.setImageResource(R.drawable.flower_r2_c3);
			}
		}
		if (position==5) {
			if (data_list.get(position).isIscheck()) {
				holder.imageView.setImageResource(R.drawable.flower_r2_c4_press);
			}else {
				holder.imageView.setImageResource(R.drawable.flower_r2_c4);
			}
		}
		
		return convertView;
	}

	class ViewHolder {
		private ImageView imageView;
	}

}
